package kr.co.exight.onApp;

import library.ExPreferenceManager;
import library.Variables;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

public class ActivityMap extends MapActivity implements OnClickListener {

	/** Called when the activity is first created. */
	private Button btnToggle;
	private ExPreferenceManager pm;
	private MapController mapController;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.act_mapview);
		
		btnToggle = (Button)findViewById(R.id.campusMap_btnToggle);
		btnToggle.setOnClickListener(this);
		
		pm = new ExPreferenceManager(this);
		
	    MapView mapView = (MapView) findViewById(R.id.campusMap_mapView);
		//	mapView.setOnTouchListener(mOnTouchListener);
		
	    mapView.setClickable(true);
		
		mapController = mapView.getController();	
		mapController.setZoom(17);	
		
		if(pm.getItem("MODE_YIC").equals("true")){
			btnToggle.setText("신촌");
			mapController.setCenter(Variables.YICPoint);
		}else {
			mapController.setCenter(Variables.yonSeiPoint);
		}
	}

	public void onClick(View v) {
		
		if(btnToggle.getText().equals("신촌")){
			pm.putItem("MODE_YIC", "");
			btnToggle.setText("국캠");
			mapController.setCenter(Variables.yonSeiPoint);
			
		}else if(btnToggle.getText().equals("국캠")){
			pm.putItem("MODE_YIC", "true");
			btnToggle.setText("신촌");
			mapController.setCenter(Variables.YICPoint);
		}	
	}
	
	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}

}
